home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
vol_300
/
334_01
/
electron.dem
< prev
next >
Wrap
Text File
|
1991-02-04
|
2KB
|
99 lines
# Electronics demo
#
# Bipolar Transistor (NPN) Mutual Characteristic
Ie(Vbe)=Ies*exp(Vbe/kT_q)
Ic(Vbe)=alpha*Ie(Vbe)+Ico
alpha = 0.99
Ies = 4e-14
Ico = 1e-09
kT_q = 0.025
set dummy Vbe
set grid
set offsets
set nolog
set nopolar
set samples 160
set title "Mutual Characteristic of a Transistor"
set xlabel "Vbe (base emmitter voltage)"
set xrange [0 : 0.75]
set ylabel "Ic (collector current)"
set yrange [0 : 0.005]
set key .2,.0045
set format y "%.4f"
plot Ic(Vbe)
set format "%g"
pause -1 "Hit return to continue"
# Junction Field Effect Transistor (JFET) Mutual Characteristic
# drain current above pinch off
Ida(Vd)=Ido*(1-Vg/Vp)**2
# drain current below pinch off
Idb(Vd)=Ido*(2*Vd*(Vg-Vp)-Vd*Vd)/(Vp*Vp)
# drain current
Id(Vd)= (Vd>Vg-Vp) ? Ida(Vd) : Idb(Vd)
# drain current at zero gate voltage
Ido = 2.5
# pinch off voltage
Vp = -1.25
# gate voltage
Vg = 0
set dummy Vd
set nogrid
set nokey
set offsets 0, 1, 0, 0
set title "JFET Mutual Characteristic"
set xlabel "Drain voltage Vd (V)"
set xrange [0 : 4]
set ylabel "Drain current Id (mA)"
set yrange [0 : 5]
set label "-0.5 Vp" at 4.1,0.625
set label "-0.25 Vp" at 4.1,1.4
set label "0" at 4.1,2.5
set label "Vg = 0.5 Vp" at 4.1,3.9
plot Vg=0.5*Vp,Id(Vd),Vg=0.25*Vp,Id(Vd),Vg=0,Id(Vd),Vg=-0.25*Vp,Id(Vd)
set nolabel
pause -1 "Hit return to continue"
# amplitude frequency response
A(jw) = ({0,1}*jw/({0,1}*jw+p1)) * (1/(1+{0,1}*jw/p2))
p1 = 10
p2 = 10000
set dummy jw
set grid
set key
set logscale xy
set offsets 0, 0, 0, 0
set title "Amplitude Frequency Response"
set xlabel "jw (radians)"
set xrange [1.1 : 90000.0]
set ylabel "magnitude of A(jw)"
set autoscale y
plot abs(A(jw))
pause -1 "Hit return"
# phase frequency response
set nolog y
set logscale x
set title "Phase Frequency Response"
set ylabel "Phase of A(jw) (degrees)"
plot 180/pi*arg(A(jw))
pause -1 "Hit return"
# undo what we've done
set dummy x
set nogrid
set offsets 0,0,0,0
set title ""
set ylabel ""
set xlabel ""
set xrange [-10:10]
set autoscale xy
set key
set format xy "%g"
set nolabel
set nolog